package com.cat.twoPointerTechnique;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/find-the-power-of-k-size-subarrays-ii/
 * @create 2025/8/9 08:15
 * @since JDK17
 */

public class Solution28 {
    public int[] resultsArray(int[] nums, int k) {
        int n = nums.length, m = n - k + 1;
        int[] ans = new int[m];
        for (int i = 0, j = 1; i < m; ) {
            while (j < i + k && nums[j - 1] + 1 == nums[j]) {
                j++;
            }
            if (j == i + k) {
                ans[i++] = nums[j - 1];
                continue;
            }
            int start = j;
            while (i < j) {
                ans[i++] = -1;
            }
        }

        return ans;
    }
}
